#define _CRT_SECURE_NO_WARNINGS


#include <stdio.h>

void PrintArrar(int* a, int n)
{
	for (int i = 0; i < n; ++i)
	{
		printf("%d ", a[i]);
	}
	printf("\n");
}

void InsertSrot(int* a, int n)
{
	for (int i = 0; i < n - 1; ++i)
	{
		int end = i;
		int tmp = a[end + 1];
		while (end >= 0)
		{
			if (a[i] > tmp)
			{
				a[end + 1] = a[end];
				--end;
			}
			else
			{
				break;
			}
		}
		a[end + 1] = tmp;
	}
}

void TestInsertSort()
{
	int arr[] = { 9,8,7,6,5,4,3,2,1 };
	InsertSrot(arr, sizeof(arr) / sizeof(int));
	PrintArrar(arr, sizeof(arr) / sizeof(int));
}

int main()
{
	TestInsertSort();
	return 0;
}
